package cn.iotab.iotkit.transport.mqtt.adaptors;

import cn.iotab.iotkit.transport.api.common.message.msg.CommonPayload;
import cn.iotab.iotkit.transport.mqtt.session.MqttSessionCtx;
import io.netty.handler.codec.mqtt.MqttMessage;
import io.netty.handler.codec.mqtt.MqttPublishMessage;

import java.util.Optional;

/**
 * @author Andrew Shvayka
 */
public interface MqttTransportAdaptor {

    CommonPayload convertFromDeviceRequest(String productKey, String deviceId, MqttPublishMessage mqttMsg) throws AdaptorException;

    CommonPayload convertFromDeviceResponse(String productKey, String deviceId, MqttPublishMessage mqttMsg) throws AdaptorException;

    Optional<MqttMessage> convertToDeviceRequest(MqttSessionCtx ctx, CommonPayload toDeviceRequest);

    Optional<MqttMessage> convertToDeviceResponse(MqttSessionCtx ctx, CommonPayload toDeviceResponse);
}
